//package com.yc.cloud.portal.config;
//
//import com.yc.cloud.common.basic.api.ResponseStatus;
//import com.yc.cloud.common.swagger.config.BaseSwaggerConfig;
//import com.yc.cloud.common.swagger.config.SwaggerProperties;
//import org.springframework.boot.actuate.autoconfigure.endpoint.web.CorsEndpointProperties;
//import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
//import org.springframework.boot.actuate.autoconfigure.web.server.ManagementPortType;
//import org.springframework.boot.actuate.endpoint.ExposableEndpoint;
//import org.springframework.boot.actuate.endpoint.web.*;
//import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointsSupplier;
//import org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.env.Environment;
//import org.springframework.util.StringUtils;
//import springfox.documentation.builders.ResponseBuilder;
//import springfox.documentation.oas.annotations.EnableOpenApi;
//import springfox.documentation.service.Response;
//
//import java.util.ArrayList;
//import java.util.Collection;
//import java.util.List;
//
///**
// * Swagger API文档相关配置
// */
//@Configuration
//@EnableOpenApi
//public class SwaggerConfig extends BaseSwaggerConfig {
//
//    @Override
//    public SwaggerProperties swaggerProperties() {
//        return SwaggerProperties.builder()
//                .apiBasePackage("com.yc.cloud.portal.controller")
//                .title("门户网站")
//                .description("客户端相关接口文档")
//                .contactName("Yancy")
//                .version("1.0")
//                .enableSecurity(true)
//                .globalResponseMessage(getGlobalResponseMessage())
//                .build();
//    }
//
//    /**
//     * 封装通用响应信息
//     */
//    private List<Response> getGlobalResponseMessage() {
//        List<Response> responseList = new ArrayList<>();
//        responseList.add(new ResponseBuilder().code(String.valueOf(ResponseStatus.FAILED.getCode())).description(ResponseStatus.FAILED.getMessage()).build());
//        responseList.add(new ResponseBuilder().code(String.valueOf(ResponseStatus.SUCCESS.getCode())).description(ResponseStatus.SUCCESS.getMessage()).build());
//        responseList.add(new ResponseBuilder().code(String.valueOf(ResponseStatus.VALIDATE_FAILED.getCode())).description(ResponseStatus.VALIDATE_FAILED.getMessage()).build());
//        responseList.add(new ResponseBuilder().code(String.valueOf(ResponseStatus.UNAUTHORIZED.getCode())).description(ResponseStatus.UNAUTHORIZED.getMessage()).build());
//        responseList.add(new ResponseBuilder().code(String.valueOf(ResponseStatus.FORBIDDEN.getCode())).description(ResponseStatus.FORBIDDEN.getMessage()).build());
//        responseList.add(new ResponseBuilder().code(String.valueOf(ResponseStatus.NOT_FOUND.getCode())).description(ResponseStatus.NOT_FOUND.getMessage()).build());
//        return responseList;
//    }
//
//    @Bean
//    public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(
//            WebEndpointsSupplier webEndpointsSupplier,
//            ControllerEndpointsSupplier controllerEndpointsSupplier,
//            EndpointMediaTypes endpointMediaTypes,
//            CorsEndpointProperties corsProperties,
//            WebEndpointProperties webEndpointProperties,
//            Environment environment) {
//
//        List<ExposableEndpoint<?>> allEndpoints = new ArrayList<>();
//        Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
//        allEndpoints.addAll(webEndpoints);
//        allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
//
//        String basePath = webEndpointProperties.getBasePath();
//        EndpointMapping endpointMapping = new EndpointMapping(basePath);
//        boolean shouldRegisterLinksMapping = shouldRegisterLinksMapping(webEndpointProperties, environment, basePath);
//
//        return new WebMvcEndpointHandlerMapping(endpointMapping, webEndpoints, endpointMediaTypes,
//                corsProperties.toCorsConfiguration(), new EndpointLinksResolver(allEndpoints, basePath),
//                shouldRegisterLinksMapping);
//    }
//
//    private boolean shouldRegisterLinksMapping(WebEndpointProperties webEndpointProperties, Environment environment, String basePath) {
//        return webEndpointProperties.getDiscovery().isEnabled() &&
//                (StringUtils.hasText(basePath) || ManagementPortType.get(environment).equals(ManagementPortType.DIFFERENT));
//    }
//}
